package com.example.demo.util;

import java.lang.reflect.Field;

/**
 * 对象判空
 * 
 * @author shoukui
 *
 */
public class ObjectUtil {
	/**
	 * 找出对象中的空属性
	 * 
	 * @param o
	 * @return
	 * @throws Exception
	 */
	public static Field findIsEmpty(Object o) throws Exception {
		Field[] declaredFields = o.getClass().getDeclaredFields();
		for (Field field : declaredFields) {
			field.setAccessible(true);
			if (field.get(o) != null && StringUtil.isNotEmpty(field.get(o).toString())) {
				continue;
			} else {
				return field;
			}
		}
		return null;
	}
}
